package HOT100;

/**
 * @author 是阿秋啊
 * @date 2022/07/21 20:37
 **/
public class num11 {
    // 双指针加短走长不走的思想,可以性能优化通过测试用例
    // 双for循环时间复杂度太高
    // https://leetcode.cn/problems/container-with-most-water/
    int max = Integer.MIN_VALUE;
    public int maxArea(int[] height) {
        int i = 0;
        int j = height.length - 1;
        while(i < j) {
            max = Math.max(max,Math.min(height[i],height[j])*(j - i));
            if(height[i] < height[j]) {
                i++;
            }else{
                j--;
            }
        }
        return max;
    }
}